<?php

/*
    Open Designs Content Management System (odCMS)
    Copyright (C) 2010  Thomas Wong - tom@ztml.org

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
*/

if($_GET['type'] == "info")
{
        phpinfo();
        exit;
}

if($_REQUEST['usite'])
{
	$page = "index.php";
	if($_REQUEST['Page']) $page .= "?Page=".$_REQUEST['Page'];

	chdir("../");
	
	if($_SERVER["DOCUMENT_ROOT"]==getcwd())
	{
		header("location: /".$_REQUEST['usite']."/$page");
		echo "<h3>Error encountered while redirecting...</h3><a href='/'>Click here to continue...</a>";
		exit;
	}
	preg_match("/.*([\\\|\/])([a-zA-Z0-9_]+)$/", getcwd(), $dirs);
	header("location: /$dirs[2]/".$_REQUEST['usite']."/$page");
	
	echo "<h3>Error encountered while redirecting...</h3><a href='/'>Click here to continue...</a>";
	exit;
}

session_start();

if($_SESSION['usite']) unset($_SESSION['usite']);

$DIR = "../codes/";

if(file_exists("./cc_functions.php") )
{
	include_once ("./cc_functions.php");
}
else
{
	include_once ($DIR.'cc_functions.php');
}
include_once ($DIR.'cc_init.php');
include_once ($DIR.'cc_io.php');
include_once ($DIR.'cc_class.php');
include_once ($DIR.'cc_update.php');

if($_REQUEST['Update']) $cc = new contentUpdate();
else $cc = new contentControl();

exit;
 
?>

